#ifndef GLOBAL_H
#define GLOBAL_H

#include <QString>
#include <QStringList>
#include <QMap>
#include <QApplication>
#include <QDir>
#include <QSettings>
#include <QFile>

// 参数基础类型
typedef enum ParamBaseType{
    PBType_INT8 = 0,
    PBType_INT16,
    PBType_INT32,
    PBType_INT64,
    PBType_UINT8,
    PBType_UINT16,
    PBType_UINT32,
    PBType_UINT64,
    PBType_Float,
    PBType_Double,
    PBType_Date,
    PBType_Time,
    PBType_DateTime
}ePBType;

typedef enum ParamOptionAccess{
    PO_ReadWrite = 0,
    PO_WriteOnly,
    PO_ReadOnly
}eParamOptionAccess;


class Global
{
public:
    static Global* instance();

    QString paramTypeToString(ePBType type);
    ePBType stringToParamType(QString str);
    QStringList paramTypeStringList();

    QString accessToString(eParamOptionAccess access);
    eParamOptionAccess stringToAccess(QString str);
    QStringList accessStringList();

    bool loadConfig();
    bool saveConfig();

    QString lastFileName() const;
    void setLastFileName(const QString &lastFileName);

private:
    Global();
    static Global* _instance;

    QMap<ePBType, QString> m_ParamTypeMap;
    QMap<eParamOptionAccess, QString> m_OptionAccessMap;

    QString m_lastFileName;
    QString m_strConfigFileName;
};

#endif // GLOBAL_H
